﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TuringMachineSimulator;
using System.Threading;

namespace TuringMachineSimulator
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_Validating(object sender, CancelEventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            textTape.ResetText();
            Application.DoEvents();

            TuringSimulator simulator = new TuringSimulator();
            //simulator.TuringTransitionCompleted += new TuringTransitionCompletedHandler(simulator_TuringTransitionCompleted);
            string summary = simulator.Run(textFile.Text.Trim(), textInput.Text.Trim(), panel1.CreateGraphics(), Int16.Parse(textDelay.Text));

            //Simlator also returns the summary of processing apart from drawing the tape to graphics context.
            textTape.ResetText(); textTape.Text = summary;

            
        }
       

        void simulator_TuringTransitionCompleted(object sender, EventArgs e)
        {
            //MessageBox.Show("One Transition completed");
        }

        private void button2_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                textFile.Text = openFileDialog1.FileName;
            }
        }

      
    }
}
